import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 首页
  {
    path: '/',
    name: 'index',
    component: () => import('@/views/Index'),
    redirect: '/postlist',
    meta: {
      name: '首页'
    },
    children: [{
      // 子路由：文章列表
      path: 'postlist',
      name: 'postlist',
      component: () => import('@/views/Postlist'),
      meta: {
        name: '文章列表'
      }
    }, {
      // 子路由：发布文章
      path: 'postpublish',
      name: 'postpublish',
      component: () => import('@/views/Postpublish'),
      meta: {
        name: '发布文章'
      }
    }]
  },
  // 登录页
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login')
  }
]

const router = new VueRouter({
  routes
})

export default router